<template>
  <el-dropdown trigger="click" class="international" @command="handleSetLanguage">
    <div class="lang-select">
      <!--      <svg-icon class-name="international-icon" icon-class="language" />-->
      {{ $t('lang_select') }}
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="language==='zh'" command="zh">
        中文
      </el-dropdown-item>
      <el-dropdown-item :disabled="language==='en'" command="en">
        English
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>

import getPageTitle from '@/utils/get-page-title'
export default {

  computed: {
    language() {
      return this.$store.getters.language
    }
  },
  methods: {
    handleSetLanguage(lang) {
      this.$i18n.locale = lang
      this.$store.dispatch('app/setLanguage', lang)
      this.$message({
        message: 'Switch Language Success',
        type: 'success'
      })

      // 摁改title
      if (lang === 'en') { document.title = 'Large Language Model Low Dependency AI Agent Development Environment' } else { document.title = '大模型低依赖的AI智能体开发环境' }
      // 修改语言后，侧边栏菜单项不会立即改变，刷新页面以重新加载对应的组件
      location.reload()
    }
  }
}
</script>

<style lang="scss">

  .lang-select {
    cursor: pointer;
  }

</style>
